package idv.cjcat.pyronova.nodes {
	import flash.filters.ColorMatrixFilter;
	import flash.geom.Point;
	import idv.cjcat.pyronova.render.Graphics;
	import idv.cjcat.pyronova.render.RenderVisitor;
	import idv.cjcat.pyronova.utils.ColorMatrix;
	
	public class Grayscale extends Node {
		
		private var _filter:ColorMatrixFilter;
		
		public function Grayscale() {
			_filter = new ColorMatrixFilter(
				ColorMatrix.GRAYSCALE
			);
		}
		
		private var g:Graphics;
		private var point:Point = new Point();
		override public function render(visitor:RenderVisitor):void {
			g = visitor.graphics();
			g.topBuffer().applyFilter(g.topBuffer(), g.rect(), point, _filter);
		}
	}
}